<template>
    <h1>EL-消息提示组件</h1>
    <el-button @click="f(1)" type="success">成功消息</el-button>
    <el-button @click="f(2)" type="danger">失败消息</el-button>
    <el-button @click="f(3)" type="warning">警告消息</el-button>
    <el-button @click="f(4)" type="info">普通消息</el-button>
    <el-button @click="f(5)" type="primary">可关闭消息</el-button>
</template>

<script setup>
// 注意！ElMessage需要导入！
import { ElMessage } from 'element-plus';

//定义函数用来弹出不同类型的消息提示
const f = (type) => {
    switch (type) {
        case 1:
            ElMessage.success('这是一条成功消息');
            break;
        case 2:
            ElMessage.error('这是一条失败消息');
            break;
        case 3:
            ElMessage.warning('这是一条警告消息');
            break;
        case 4:
            ElMessage.info('这是一条普通消息提示');
            break;
        case 5:
            ElMessage.success({
                message: '这是一条可关闭消息',
                showClose: true,
                duration: 9000
            });
    }
}
</script>

<style scoped>

</style>